// ssr-mock.js
if (typeof window === 'undefined') {
  // 模拟全局 window 对象
  global.window = {
    addEventListener: () => {},
    removeEventListener: () => {},
    location: { href: '', pathname: '' },
    navigator: { userAgent: 'SSR' },
    requestAnimationFrame: (cb) => setTimeout(cb, 0),
    cancelAnimationFrame: (id) => clearTimeout(id),
  };

  // 模拟全局 document 对象
  global.document = {
    addEventListener: () => {},
    removeEventListener: () => {},
    createElement: () => ({ 
      addEventListener: () => {},
      style: {},
      getContext: () => ({}),
    }),
    querySelector: () => null,
    getElementById: () => null,
    body: { appendChild: () => {}, style: {} },
    head: { appendChild: () => {} },
  };

  // 其他可能需要的浏览器 API
  global.Image = class MockImage {};
  global.localStorage = {
    getItem: () => null,
    setItem: () => {},
    removeItem: () => {},
  };
}